package com.fantsey.pattern.observer;

public class BinaryObserver extends Observer {

    // 选择并初始化被观察的主类，并把当前观察者加入到观察者集合中
    public BinaryObserver(Subject subject){
        this.subject = subject;
        this.subject.attach(this);
    }

    // 更新依赖的对象
    @Override
    public void update() {
        System.out.println( "Binary String: "
                + Integer.toBinaryString( subject.getState() ) );
    }
}
